/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.reader.dao;

import android.content.Context;
import android.database.Cursor;

public abstract class Dao {
	protected final DBHelper db;

	public Dao(Context paramContext) {
		this.db = new DBHelper(paramContext);
	}

	public void close() {
		this.db.close();
	}

	public void delete(int paramInt) {
		this.db.delete(paramInt);
	}

	public void deleteAll() {
		Cursor localCursor = this.db.query(new String[] { "id" }, null, null,
				null, null, null);
		deleteAll(localCursor);
		localCursor.close();
	}

	public void deleteAll(int paramInt) {
		DBHelper localDBHelper = this.db;
		String[] arrayOfString1 = { "id" };
		String[] arrayOfString2 = new String[1];
		arrayOfString2[0] = String.valueOf(paramInt);
		deleteAll(localDBHelper.query(arrayOfString1, "type = ?",
				arrayOfString2, null, null, null));
	}

	public void deleteAll(Cursor paramCursor) {
		if (paramCursor.getCount() > 0)
			paramCursor.moveToFirst();
		while (true) {
			if (paramCursor.isAfterLast())
				return;
			delete(paramCursor.getInt(0));
			paramCursor.moveToNext();
		}
	}

	public boolean toBoolean(int paramInt) {
		return (paramInt == 1);
	}
}